import React, { useState, useEffect } from 'react';
import { findFilmsPage } from '@/api/MaiZuo';

export default function FilmList(props) {
  const [list, setList] = useState([]);

  useEffect(() => {
    findFilmsPage(1, 10, props.type).then((res) => {
      console.log('films', res);

      setList(res.films);
    });
    return () => {};
  }, [props.type]);

  return (
    <ul>
      {list.map((item) => {
        return <li key={item.filmId}>{item.name}</li>;
      })}
    </ul>
  );
}
